You are here: Custom Study Programming > Reference > Classes > StudyData > StudyData Methods > insert

insert

The insert method inserts a new floating value at the specified index for the in-memory dataset of a given StudyData object.

 

Syntax

insert(index, floatValue);

Parameters

index

Index specifies the location where to insert the floating value.

 

floatValue

Floating value that will be inserted and stored in memory.

Example

The following example demonstrates how to insert a value into a StudyData object.

 

function calculate(beginIndex, endIndex)

{

var studyData = this.getStudyData("customSMA");

if(studyData != null)

{

//calculate new value and insert it at the end

 

var newValue = calculateRandomValue();

studyData.insert(studyData.count(), newValue);

}

}

 

function calculateRandomValue()

{

//calculate some random value, and return it to the caller

 

var randomValue = Math.rand();

return randomValue;

}

 


Copyright © 2006-2009 ActiveTick LLC